package tree;
import java.awt.Component;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

import main.Interface;


public class MyTreeCellRenderer extends DefaultTreeCellRenderer {

	private static final long serialVersionUID = 1L;
	
	private final Icon fileDate;
	private final Icon fileNumber;
	private final Icon filePath;
	
	public MyTreeCellRenderer(){
		fileDate = new ImageIcon(Interface.class.getResource("/small/calendar_full.png"));
		fileNumber = new ImageIcon(Interface.class.getResource("/small/copy_page.png"));
		filePath = new ImageIcon(Interface.class.getResource("/small/save.png"));
	}

	@Override
	public Component getTreeCellRendererComponent(JTree tree, Object node,
			boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
		
		if(node instanceof FileDateNode) this.setLeafIcon(fileDate);
		else if (node instanceof FileNumberNode) this.setLeafIcon(fileNumber);
		else if (node instanceof PathNode) this.setLeafIcon(filePath);
		
		return super.getTreeCellRendererComponent(tree, node, sel, expanded, leaf, row, hasFocus);
	}

}
